<?php
namespace Org\Util;
class Listdir{
private $depth;
private $dirname;
private $list;
private $tostring;

public function __construct($dir){
$this->dirname=$dir;
$this->depth=0;
$this->tostring="";
}

//把结果保存进多维数组
function getlist($dir=""){
if($dir=="") $dir=$this->dirname;
$d=@dir($dir);
while(false!==($item=$d->read()))
{
if($item!="."&&$item!="..")
{
$path=$dir.$item;
if(is_dir($path)){
$this->depth+=1;
$this->getlist($path);
}else{
$this->list[$this->depth][]=$item;
}
}
}
$this->list[$this->depth]['directory']=$dir;
$this->depth-=1;
$d->close();
return $this->list;
}


}
?>